package com.boot.mall.third.controller;

import com.boot.common.utils.R;
import com.boot.mall.third.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/Oss/policy")
public class OssController {

    @Autowired
    private OssService ossService;

    //上传头像
    @PostMapping
    public R uploadOssFile(@RequestParam("file") MultipartFile multipartFile){
        //获取上传文件   MultipartFile
        //返回上传到OSS的路径
        String url = ossService.uploadFileAvatar(multipartFile);
        return R.ok().put("data",url);
    }

}
